package com.service.database.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 数据模型
 * @author xianggj
 * @Date 2021/6/4 22:16
 **/
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
public class DataModel implements Serializable{

    private static final long serialVersionUID = -9882321123779L;

    /**
     * 数据数量
     */
    private long count;

    /**
     * 表名
     */
    private String tableName;

    /**
     * 表注释
     */
    private String comment;

    /**
     * 真实数据
     */
    private List<Map<String, Object>> datas = new ArrayList<>();

    /**
     * 列信息 和数据顺序一一对应
     */
    private List<DataColumn> columns = new ArrayList<>();


    public List<String> getColumNames() {
        return columns.stream().map(e->e.getColumnName()).collect(Collectors.toList());
    }

}
